/**
 * long description for the file
 *
 * @summary 菜单接口
 * @author wu[308822989@qq.com]
 *
 * Created at     : 2018-12-28 13:29:05
 * Last modified  : 2019-01-04 14:25:13
 */

import request from '../../utils/request'

export function list(params) {
  return request({
    url: '/admin/menu/index',
    method: 'get',
    params
  })
}

export function del(items) {
    let ids = [];
    items.forEach(element => {
        ids.push(element.role_id);
    });
    return request({
      url: '/admin/role/destory',
      method: 'post',
      data: {role_ids: ids.join(',')}
    })
}

export function add(data) {
    //  菜单转json文本
    let str = JSON.stringify(data.role_menus);
    return request({
      url: '/admin/role/store',
      method: 'post',
      data: {...data, role_menus: str}
    })
}

export function info(data) {
  return request({
    url: '/admin/role/info',
    method: 'get',
    params: {role_id: data.role_id}
  })
}

